
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin")
const { merge } = require("webpack-merge");
const config = require("./webpack.base");

/**
 * 客户端的webpack
 */
const clientConfig = {
  mode: "development",
  // 客户端入口
  entry: "./client/index.js",
  // 客户端输出
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "public")
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: "index.csr.html",
      template: "src/index.csr.html"
    })
  ],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              importLoaders: 1,
              modules: {
                localIdentName: "[name]_[local]_[hash:base64:5]",
              },
            },
          }
        ]
      }
    ]
  }
}

module.exports = merge(config, clientConfig);